﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using IOEntity;
using IODataAccess;
namespace IOBusiness
{
    public class clsBSTour
    {
        clsDATour obj = new clsDATour();
        public clsTour GetById(int id)
        {
            try
            {
                return obj.GetById(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsTour> GetAll()
        {
            try
            {
                return obj.GetAll();
            }
            catch (Exception)
            {

                throw;
            }

        }
        public List<clsTour> GetByHostTour(int top)
        {
            try
            {
                List<clsTour> t = new List<clsTour>();
                t=obj.GetByHostTour();
                for (int i = 0; i < t.Count; i++)
                {
                    if (i > top)
                    {
                        t.RemoveAt(i);
                        i--;
                    }
                }
                return t;
            }
            catch (Exception)
            {
                
                throw;
            }
        }
        public List<clsTour> GetByHostTour()
        {
            try
            {
                return obj.GetByHostTour();
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsTour> GetByLoai(int loaiid)
        {
            try
            {
                return obj.GetByLoai(loaiid);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsTour> GetByLoai(int loaiid, int id)
        {
            try
            {
                List<clsTour> loai1 = new List<clsTour>();
                List<clsTour> loai2 = new List<clsTour>();
                loai1 = obj.GetByLoai(loaiid);
                for (int i = 0; i < loai1.Count; i++)
                {
                    if (loai2.Count < 10 & loai1[i].Id != id)
                    {
                        loai2.Add(loai1[i]);
                    }
                }
                return loai2;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsTour> GetByTop(int top)
        {
            try
            {
                return obj.GetByTop(top);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public bool Insert(clsTour to)
        {
            clsDATour d = new clsDATour();
            return d.InsertTour(to);
        }
        public bool Edit(clsTour to)
        {
            clsDATour d = new clsDATour();
            return d.EditTour(to);
        }
        public bool Del(clsTour to)
        {
            clsDATour d = new clsDATour();
            return d.DeleteTour(to);
        }
    }
}
